<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title></title>
    <link href="css/commons.css" type=text/css  rel="stylesheet">
</head>
<body >
<div class="mall" >
    <div class="mall-top clearfix">
        <div class="mall-close"  data-log="orderCloseClick" data-into="3" id="payUIClose">

        </div>
    </div>
    <div class="jihuo-logo jihuo-key">
        <img src="images/logo_in.png">
    </div>
    <div class="key-center-title">
        <h3 >你的Office密钥</h3>
    </div>
    <div class="key-center">
        <img src="images/pic_1.png">
    </div>
    <div class="keyword">
        <p class="sec" id="sec"></p>
    </div>
    <div class="key-title">
         <p>请点击<span class="btnclick" id="getClick" data-log="activateClick">立即激活</span>前往微软官网完成激活, 并返回该应用完成登录, 即可使用Office</p>
    </div>
    <div class="key-bottom">
        <p  class="btnclick" data-log="activateClick" id="btnclick">立即激活(<span>A</span>)</p>
    </div>

    <div class="layer layer2 clearfix">
        <div class="lay-close">
            <img src="images/icon_close_default.png" class="btnclose">
        </div>
        <div class="layer-btn">
            <button class="btns btn-no btn-k" id="btn-no">知道了(<span>K</span>)</button>
        </div>
    </div>

    <input type="hidden" name="paySuccessedOrder" value="paySuccessedOrder" id="fagepage">
</div>
    <script src="js/jquery.min.js"></script>
    <script>
       var queryOrder='http://officeplus.zhuazi.com/office/order/queryOrder';
       var log='http://officeplus.zhuazi.com/office/log/log/';
        var token ;
        var channel;
        var edition;
        var sys;
        var cpuid;
        var main;
        window.onload=function (){
            window.external.GetPayMsg();
            window.external.CurrentPro();
        };
        /*获取密钥*/
        function getPaySys (obj,obj2,obj3,obj4,obj5){
            token=obj;
            channel=obj2;
            edition=obj3;
            sys=obj4;
            cpuid=obj5;
            var sendData = {
                token: token
            };
            Ajax('post', queryOrder, sendData, function (data) {
                var jsons = data;
                var res;
                if (typeof(JSON) == 'undefined') {
                    res = eval("(" + jsons + ")");
                } else {
                    res = JSON.parse(jsons);
                }
                if (res.code == 200) {
                    var sec = document.getElementById("sec");
                    sec.innerHTML = res.data.secretkey;
                }

            }, function (error) {

            });
            main=$("#fagepage").val();
            tab(main,true)
        }

            function Ajax(type, url, data, success, failed) {
                // 创建ajax对象
                var xhr = null;
                if (window.XMLHttpRequest) {
                    xhr = new XMLHttpRequest();
                } else {
                    xhr = new ActiveXObject('Microsoft.XMLHTTP')
                }

                var type = type.toUpperCase();
                // 用于清除缓存
                var random = Math.random();

                if (typeof data == 'object') {
                    var str = '';
                    for (var key in data) {
                        str += key + '=' + data[key] + '&';
                    }
                    data = str.replace(/&$/, '');
                }

                if (type == 'GET') {
                    if (data) {
                        xhr.open('GET', url + '?' + data, true);
                    } else {
                        xhr.open('GET', url + '?t=' + random, true);
                    }
                    xhr.send();

                } else if (type == 'POST') {
                    xhr.open('POST', url, true);
                    xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
                    xhr.send(data);
                }

                // 处理返回数据
                xhr.onreadystatechange = function () {
                    if (xhr.readyState == 4) {
                        if (xhr.status == 200) {
                            success(xhr.responseText);
                        } else {
                            if (failed) {
                                failed(xhr.status);
                            }
                        }
                    }
                }
            }
        var payUIClose = document.getElementById("payUIClose");
        var btnNo = document.getElementById("btn-no");
        payUIClose.onclick=function (){
            $(".layer2").show()
        };
        btnNo.onclick=function (){
           window.external.CloseWnd('key')
        };
        $(".btnclose").click(function(){
            $(".layer2").hide()
        });
        var btnclick = document.getElementById("btnclick");
        btnclick.onclick=function (){
            window.external.StartActivate('https://setup.office.com/');
            var detail=$(this).attr("data-log");
            tab(detail,true)
        };

        /*日志*/
        function tab(name,boolen){
            $.ajax({
                type:'GET',
                url:log+ name+'/'+ channel+'/'+ edition + '/'+sys+'/'+cpuid,
                dataType: 'json',
                async:boolen,
                success:function(res) {
                    if(res.code==200){

                    }
                },
                error:function(err) {

                }
            });
        }

        function getColor(data){
            var getBorder=document.getElementById("sec");
            var getSize=document.getElementById('getClick');
            var getbackground=document.getElementById('btnclick');
            if(data=='word'){
                getBorder.style.borderColor="#2b579a";
                getSize.style.color="#2b579a";
                getbackground.style.background='#2b579a'
            }else if(data=='excel'){
                    getBorder.style.borderColor="#217346";
                    getSize.style.color="#217346";
                    getbackground.style.background='#217346'
            }else if(data=='ppt'){
                getBorder.style.borderColor="#b7472a";
                getSize.style.color="#b7472a";
                getbackground.style.background='#b7472a'
            }
        }
document.oncontextmenu = function(){
    event.returnValue = false;
};













    </script>
</body>
</html>